//
//  VoiceRecord.h
//  YiqiMobile
//
//  Created by henry on 13-3-30.
//  Copyright (c) 2013年 henry. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#include "lame.h"

@protocol VoiceRecordDelegate <NSObject>
@optional
-(void) convertTomp3Success:(NSString*)fileUrl;
@end
@interface VoiceRecord : NSObject<AVAudioPlayerDelegate>

@property(nonatomic,assign) BOOL  hasCAFFile;
@property(nonatomic,assign) BOOL  recording;
@property(nonatomic,assign) BOOL  playing;
@property(nonatomic,assign) BOOL hasMp3File;
@property(nonatomic,assign) BOOL  playingMp3;
@property(nonatomic,strong) NSURL*  recordedFile;
@property(nonatomic,assign) CGFloat sampleRate;
@property(nonatomic,assign) AVAudioQuality quality;
@property(nonatomic,assign) NSInteger  formatIndex;
@property(nonatomic,strong) NSTimer*    timer;
@property(nonatomic,strong) NSDate*       startDate;
@property(nonatomic,strong) AVAudioRecorder * recorder;
@property(nonatomic,strong) AVAudioPlayer *mp3Player;
@property(nonatomic,strong)  NSString *duration;
@property(nonatomic,assign)  NSInteger fileSize;
//@property(nonatomic,strong)  NSString *filePath;
@property(nonatomic,weak) id<VoiceRecordDelegate> delegate;


- (IBAction) recordBtnClick:    (NSString*) antoplay;
- (IBAction) encodeBtnClick:    (NSString*) antoplay;
- (IBAction) playMp3BtnClick:   (NSString*) antoplay;
- (void) playMp3Click:(NSString*) fileUrl;
@end
